package com.ruoyi.project.outpatient.controller;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.hissystem.domain.HisDepartment;
import com.ruoyi.project.outpatient.domain.OutPatient;
import com.ruoyi.project.outpatient.domain.PatientLib;
import com.ruoyi.project.outpatient.service.OutPatientService;
import com.ruoyi.project.outpatient.service.PatientLibService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *患者库
 */


@RestController
@RequestMapping("/outpatient/patient2")
public class PatientLibController extends BaseController {

    @Autowired
    private PatientLibService patientLibService;


    /**
     * 声明单元方法：查询患者库信息
     * @param patientLib
     * @return
     */
    @PreAuthorize("@ss.hasPermi('outpatient:library:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatientLib patientLib) {
        startPage();
        List<PatientLib> list = patientLibService.selectPatientList( patientLib );
        return getDataTable(list);
    }


    /**
     * 声明单元方法：根据ID查询患者档案信息
     * @param patientId
     * @return
     */
    @PreAuthorize("@ss.hasPermi('outpatient:library:query')")
    @GetMapping(value = "/{patientId}")
    public AjaxResult getInfo(@PathVariable Long patientId) {
        return AjaxResult.success( patientLibService.selectIdPatientInfo(patientId));
    }

    /**
     * 声明单元方法：根据ID查询患者病例信息
     * @param patientId
     * @return
     */
    @PreAuthorize("@ss.hasPermi('outpatient:library:Casequery')")
    @GetMapping(value = "/case/{patientId}")
    public AjaxResult getCaseInfo(@PathVariable Long patientId) {
        return AjaxResult.success( patientLibService.selectByIdPatientCaseInfo(patientId));
    }


}
